<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>出校申请</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <script src="../element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="div">
    <el-row>
        <el-col :span="7">
            <div class="grid-content bg-purple">
                <span style="color: #FFFFFF">王凤我爱你</span>
            </div>
        </el-col>
        <el-col :span="9">
            <div class="grid-content bg-purple-dark">
                <el-container>
                    <el-header style="text-align: center; font-size: 12px">
                        <div style="margin-left: 50px;font-size: 20px">核酸检测登记</div>
                    </el-header>
                    <el-form :label-position="'left'" label-width="200px" :model="dateFrom">
                        <el-form-item label="学号/工号">
                            <el-input v-model="dateFrom.userNumber" style="width: 300px"></el-input>
                        </el-form-item>
                        <el-form-item label="检测时间">
                            <el-date-picker
                                    v-model="dateFrom.choice_datetime"
                                    type="datetime"
                                    placeholder="选择日期"
                                    value-format="yyyy-MM-dd hh:mm:ss">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item label="核酸检测结果（阴/阳）">
<!--                            <el-switch v-model="dateFrom.result"></el-switch>-->
                            <el-radio v-model="dateFrom.result" label="true">阳性</el-radio>
                            <el-radio v-model="dateFrom.result" label="false">阴性</el-radio>
                        </el-form-item>
                        <el-form-item align="center">
                            <el-button type="primary" @click="addCheckin()" style="text-align: center;">提交</el-button>
                        </el-form-item>
                    </el-form>
                </el-container>
            </div>
        </el-col>
        <el-col :span="7">
            <div class="grid-content bg-purple">
                <span style="color: #FFFFFF">王凤我爱你</span>
            </div>
        </el-col>
    </el-row>
</div>


<script>
    new Vue({
        el: "#div",
        data: {
            dateFrom: {},
            user: {},
            userInfo: {},
        },
        methods: {
            addCheckin() {
                if (this.dateFrom.userNumber != this.userInfo.userNumber) {
                    alert('学号输入与当前登录账户不一致');
                } else {
                    let param = "action=addAcid&number=" + this.dateFrom.userNumber +
                        "&datetime=" + this.dateFrom.choice_datetime +
                        "&result=" + this.dateFrom.result;
                    console.log(param);
                    axios.post("/EpidemicControlSystem_war_exploded/NucleicAcidServlet", param)
                        .then(res => {
                            if (res.data == true) {
                                alert('添加成功');
                            } else {
                                alert('已存记录')
                            }
                        })
                }
            },
            getUser() {
                axios.post("/EpidemicControlSystem_war_exploded/UserServlet", "action=user")
                    .then(res => {
                        this.user = res.data.loginUser;
                        this.userInfo = res.data.loginUserInfo;
                        this.dateFrom = res.data.loginUserInfo;
                        console.log(this.dateFrom.userNumber);
                    });
            }
        },
        created() {
            this.getUser();
        }

    });
</script>
</body>
</html>